<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>条件语句</title>
</head>
<body>
  <script>
    // var a = false
    // var b = true
    // if (a && b) {
    //   console.log("result is true");
    // } else {
    //   console.log("result is false");
    // }

    function checkHumen(age, gender) {
      // 检查年龄
      if (age > 80) {
        console.log("old👴");  
      } else if (age >= 18) {
        console.log("adult");
      } else if (age >= 6) {
        console.log("teenager");
      } else {
        console.log("kid");
      }
      // 检查性别
      if (gender === "m") {
        console.log("male");
      } else if (gender === "fe") {
        console.log("female");
      } else {
        console.log("unknow");
      }
    }
    // checkHumen(81, "xxx");

    // 分支选择: 应对多条件判断
    function printColor(color) {
      switch (color) {
        case "white":
          console.log("#fff");
          break
        case "black":
          console.log("#000");
          break
        case "red":
          console.log("#f00");
          break
        case "green":
          console.log("#0f0");
          break
        default:
          console.log("unknow");
      }
    }
    printColor("xxx");
  </script>
</body>
</html>